package com.sec.support;

public class test {

    public static void main(String[] args) {
        String s = "  String token = request.getHeader(\"token\");\n" +
                "40         System.out.println(\"请求头中带的token: \" + token);\n" +
                "41         if (StringUtils.isNoneBlank(token)) {\n" +
                "42             if (!JwtUtil.isTokenExpired(token)) {\n" +
                "43                 String username = JwtUtil.extractUsername(token);\n" +
                "44                 if (StringUtils.isNoneBlank(username) && null == SecurityContextHolder.getContext().getAuthentication()) {\n" +
                "45                     //  查询用户权限，有以下三种方式:\n" +
                "46                     //  1. 可以从数据库中加载\n" +
                "47                     //  2. 可以从Redis中加载（PS: 前提是之前已经缓存到Redis中了）\n" +
                "48                     //  3. 可以从token中加载（PS: 前提是生成token的时候把用户权限作为Claims放置其中了）\n" +
                "49 \n" +
                "50                     UserDetails userDetails = myUserDetailsService.loadUserByUsername(username);\n" +
                "51 \n" +
                "52                     UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(userDetails, null, userDetails.getAuthorities());\n" +
                "53                     authRequest.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));\n" +
                "54 \n" +
                "55                     SecurityContextHolder.getContext().setAuthentication(authRequest);\n" +
                "56                 }\n" +
                "57             }\n" +
                "58         }\n" +
                "59 \n" +
                "60         chain.doFilter(request, response);";
        for (int i = 71; i >= 1; i--) {
            s=s.replace(String.valueOf(i),"");
        }

        System.out.println(s);
    }
}
